home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2001 December
/
pcwk12201b.iso
/
Wersje pelne i specjalne
/
Winamp 2.77 i 3.0beta
/
wasabi-sdk_beta1.exe
/
studio
/
ExampleB
/
exampleB.cpp
next >
Wrap
C/C++ Source or Header
|
2001-10-08
|
9KB
|
255 lines
/*
Nullsoft WASABI Source File License
Copyright 1999-2001 Nullsoft, Inc.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Brennan Underwood
brennan@nullsoft.com
*/
// ===========================================================================
//
// NULLSOFT WASABI SDK EXAMPLE PROJECT
//
// File: ExampleB.cpp
//
//!## Purpose: This source module that contains the functions for the
//!## construction and utilization of the XML Document Display
//!## sheet of the ExampleB project.
//
// Requires: Please read Example1.cpp first.
//
// Notes: A note on the comments in this document:
//
// Notes that begin with *** are important notes that everyone
// needs to read. The other comments assist readability or
// explain the thinking behind sections of code which may not
// be immediately obvious to the novice programmer.
//
//
// GOOD MORNING, CAMPERS!
//
//
// For exampleB, we're still gonna just ignore most of this file
// and play with the ExampleBWnd.cpp file (for the most part).
//
// As before, there are a handful of things you should know about
// this file first. Most specifically, you gotta edit all the
// "//EDITME" lines. I'll tag out the info as to what all this
// stuff does inline with the code there.
//
//
// Headers, Headers, Headers, Headers.
#include "../common/std.h" // Always start with std.h
#include "../common/xlatstr.h"
#include "ExampleB.h" //EDITME
#include "ExampleBWnd.h" //EDITME
#include "resource.h"
// WCS: START vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
#include "../studio/services/servicei.h" // For the service template.
#include "../studio/services/svc_wndcreate.h"
#include "../common/SimpleWndCreate.h"
// WCS: END ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ===========================================================================
//
// Amusing static instantiations. Your component should live as a static
// data object in your primary module (well, phooey, you can put the damn
// thing anywhere -- just make sure you make one)
static WACNAME wac;
WACPARENT *the = &wac;
// WCS: START vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
WACNAME * WACNAME::myInstance = NULL;
// WCS: END ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ===========================================================================
//
// *** You MUST use a unique GUID for your WAC files.
//
// Making it be a local data item makes it easy to centralize.
// You have to return this value from the Component's getGuid() method.
//
// Trust me. This one isn't optional. Do it, and do it NOW.
// {84E9B291-1701-449c-9E7E-AB96D65BC878}
GUID exb_guid = { 0x84e9b291, 0x1701, 0x449c, { 0x9e, 0x7e, 0xab, 0x96, 0xd6, 0x5b, 0xc8, 0x78 } };
//EDITME (hint: use guidgen.exe)
// WCS: START vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// ===========================================================================
//
// *** WindowCreationServiceObject for this example.
static waServiceT<svc_windowCreate, ThingerWndCreateSvc< WACNAME > > ExampleB_WndCreateSvc;
//
// For now, in order to allow your component to create a window in the GUI
// into which it may place its functionality, you need to create the above
// template instantiation and then use it in your onRegisterServices() and
// onDestroy() calls.
//
// WCS: END ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ===========================================================================
//
// This "Fortify" stuff is nice happy memory handling and leak detection.
// You might learn about the specifics of it sometime in the future but,
// for now, change the output .WAC filenames for your debug and release
// files here.
WACNAME::WACNAME() {
#ifdef FORTIFY
FortifySetName("ExampleB.wac"); // EDITME
FortifyEnterScope();
#endif //FORTIFY
wnd = NULL;
// WCS: START vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// Helper data for the window creation service
ASSERT( myInstance == NULL );
myInstance = this;
// WCS: END ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
WACNAME::~WACNAME() {
#ifdef FORTIFY
FortifyLeaveScope();
#endif
}
// ===========================================================================
//
// Ah, well, yes. There's one problem with GUIDs. Nobody will be
// able to tell that component {6DC73FE8-6D34-4942-950A-FF2370329BB0}
// is the really kickass breadslicing component you've written for
// Winamp3.0 -- so you gotta actually give it at least a SEMI unique
// name in english, too.
const char *WACNAME::getName() {
return "ExampleB Component"; //EDITME
}
GUID WACNAME::getGUID() {
return exb_guid;
}
void WACNAME::onCreate() {
// *** Do startup stuff here that doesn't require you to have a window yet
}
// WCS: START vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
int WACNAME::destroyWindow(RootWnd * deadWnd) {
if ((deadWnd != NULL)&&(deadWnd == wnd)) {
delete deadWnd;
wnd = NULL;
return 1;
}
return 0;
}
ThingerBitmapInfo WACNAME::getThingerBitmapInfo() {
return ThingerBitmapInfo(gethInstance(), IDB_TAB_NORMAL, NULL, IDB_TAB_HILITED, IDB_TAB_SELECTED);
}
void WACNAME::onRegisterServices() {
// *** Register our window creation service here.
// If we don't do this, we don't get a window.
api->service_register(&ExampleB_WndCreateSvc);
api->register_autoPopupGUID(getGUID(), getName());
}
// WCS: END ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
void WACNAME::onDestroy() {
// WCS: START vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// *** Deregister our window creation service here.
// If we don't do this, we get a memory leak.
api->service_deregister(&ExampleB_WndCreateSvc);
// WCS: END ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// *** Be sure to delete all your windows etc HERE, not in the destructor,
// because the API pointer might be invalid in the destructor
delete wnd; wnd = NULL;
WACPARENT::onDestroy();
}
//
// When the API asks you to make your window, you make your window.
// NO.
// QUESTIONS.
// ASKED.
//
RootWnd *WACNAME::createWindow(int n, RootWnd *parentWnd) {
if (n == 0) {
//
// You've seen this before. There's nothing new here.
// We make our window, and then we grooove with it.
if (wnd != NULL)
return NULL;
wnd = new ExampleBWnd;
//
// But we're not just making a blankeyblank window for painting.
//
// Oh, no SIR!
//
// We're gonna make all KINDS of nasty windowlets in this
// mild exercise in constrained psychosis. It'll be fun.
//
// Trust me.
//
//
// So, here's the plan: we get a bunch of sea monkeys, and train them
// to use automatic weapons. Then...
//
// Errr, wait... that's this weekend's plans. Sorry.
//
// RIGHT. Found it. HERE'S the real plan:
//
// 1) Figure out how to use the Tabsheet UIO
// 2) Implement a Tabsheet UIO with LOTS of (lots of) Tabs.
// 3) Implement some examples of SDK functionality into each tabsheet.
// 4) FEEL the LOVE.
//
//
// Ready to dive in, face first?
//
// Let's go!
// ON to ExampleBWnd.cpp, my good man! MUSH!
//
wnd->init(parentWnd);
return wnd;
}
return 0;
}